{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "85cc6c7f-87bb-459b-94b7-10706713997a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4, 5]\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "--------------------\n",
      "4\n",
      "--------------------\n",
      "0 1\n",
      "1 2\n",
      "2 3\n",
      "3 4\n",
      "4 5\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'\\ncopy() 用于赋值一个列表\\ncount() 用于统计某个元素在列表中出现的次数\\nreverse() 用于将列表中的元素反向存放\\nsort() 用于对列表进行排序，调用该方法会改变原来的列表\\nsorted() 用于对列表排序，返回新列表，不对原列表做修改。\\nclear() 用于清空列表的内容\\n'"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 列表\n",
    "ls1 = [1,2,3,4,5]\n",
    "print(ls1) # [1, 2, 3, 4, 5]\n",
    "\n",
    "for n in ls1:\n",
    "    print(n)\n",
    "\n",
    "print('-' * 20)\n",
    "i = 0\n",
    "ls1_len = len(ls1)\n",
    "\n",
    "while i < ls1_len:\n",
    "    if i > 2:\n",
    "        print(ls1[i])\n",
    "        break\n",
    "    i += 1\n",
    "\n",
    "\n",
    "print('-' * 20)\n",
    "\n",
    "for i, item in enumerate(ls1):\n",
    "    # i 就是下标索引\n",
    "    # item 列表中index对应的值\n",
    "    print(i, item)\n",
    "\n",
    "\"\"\"\n",
    "copy() 用于赋值一个列表\n",
    "count() 用于统计某个元素在列表中出现的次数\n",
    "reverse() 用于将列表中的元素反向存放\n",
    "sort() 用于对列表进行排序，调用该方法会改变原来的列表\n",
    "sorted() 用于对列表排序，返回新列表，不对原列表做修改。\n",
    "clear() 用于清空列表的内容\n",
    "\"\"\""
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
